//This javascript file is separated from fe_js.js for clarity/tidiness. It does however use variables found in fe_js.js, and so must be imported to the index.php file after fe_js.js


//The following constant strings can be altered to change the message displayed in a particular scenario.

var const_LIGHT = "Has the light been turned on?";
var const_OIL1 = "Applying oil to the lens at levels of 10x or 40x magnification will only blur the vision.";
var const_OIL2 = "The resolution of light in air is too low for very high levels of magnification such as 100x; applying oil to the magnification lens is needed to focus the image.";
var const_FOCUS100 = "At the lowest level of magnification (10x, magnified by occulars to 100x), using the coarse control will bring you in focus a lot faster than the fine focus control.";
var const_FOCUS400 = "At 40x (magnified by occulars to 400x) of magnification, you may need to use the finer focus control in order to bring yourself into the best possible focus.";
var const_FOCUS1000 = "At the highest level of magnification (100x, magnified by occulars to 1000x), using the coarse focus control will quickly bring you out of focus, try using only the fine focus controls once you have found focus at a lower level of magnification.";
var const_CORRECT = "You are in focus at this level of magnification, try focusing at a higher level of magnification.";
var const_COMPLETE = "You are in focus at the highest level of magnification! Try another slide and repeat the procedure.";




function hint()
{
	if (hintdisp){
		hinthide();
	} else {
		guidedisp = false;
		$("#guide").slideUp("fast", function(){
		hintdisp = true;
		$("#hint").slideDown("fast");}
		);

		if (light == false)
		{
			$("#hintcontent").text(const_LIGHT);
			return false;
		}
		else
		{
			if ((oil && mag == 0) || (oil && mag == 1))
			{
				$("#hintcontent").text(const_OIL1);
				return false;
			}

			if (oil == false && mag == 2)
			{
				$("#hintcontent").text(const_OIL2);
				return false;
			}

			if ((focus < (focus100 - const_100RANGE) || focus > (focus100 + const_100RANGE)) && mag == 0)
			{
				$("#hintcontent").text(const_FOCUS100);
				return false;
			}

			if ((focus < (focus400 - const_400RANGE) || focus > (focus400 + const_400RANGE)) && mag == 1)
			{
				$("#hintcontent").text(const_FOCUS400);
				return false;
			}

			if ((focus < (focusPoint - const_1000RANGE) || focus > (focusPoint + const_1000RANGE)) && mag == 2)
			{
				$("#hintcontent").text(const_FOCUS1000);
				return false;
			}

			if (mag == 0 || mag == 1)
			{
				$("#hintcontent").text(const_CORRECT);
				return false;
			}

			if (mag == 2)
			{
				$("#hintcontent").text(const_COMPLETE);
				return false;
			}			
		}
	}
}

function guide(){
	if (guidedisp){
		guidehide();
	} else {
		hintdisp = false;
		$("#hint").slideUp("fast", function(){
		guidedisp = true;
		$("#guide").slideDown("fast");}
		);
		
		updateguide();
	}
	
		
}

function updateguide(){
	if (light == false)
	{
		$("#guide1").removeClass('tick');
	}else{
		$("#guide1").addClass('tick');
	}

	if ((focus < (focus100 - const_100RANGE) || focus > (focus100 + const_100RANGE)) && mag == 0)
	{
		$("#guide2").removeClass('tick');
	} else {
		$("#guide2").addClass('tick');
	}
	
	if (mag == 0)
	{
		$("#guide3").removeClass('tick');
	} else {
		$("#guide3").addClass('tick');
	}
	
	if ((focus < (focus400 - const_400RANGE) || focus > (focus400 + const_400RANGE)) && mag == 1 || mag == 0)
	{
		$("#guide4").removeClass('tick');
	} else {
		$("#guide4").addClass('tick');
	}

	if (mag < 2)
	{
		$("#guide5").removeClass('tick');
	} else {
		$("#guide5").addClass('tick');
	}
	
	if (oil == false && mag == 2 || mag < 2)
	{
		$("#guide6").removeClass('tick');
	} else {
		$("#guide6").addClass('tick');
	}
	
	if ((focus < (focusPoint - const_1000RANGE) || focus > (focusPoint + const_1000RANGE)) && mag == 2 || mag < 2)
	{
		$("#guide7").removeClass('tick');
	} else {
		$("#guide7").addClass('tick');
	}
}
